export const state = () => {
    return {
        city: "",
        history:[]
    }
}

export const mutations = {
    setCity(state, data){
        state.city = data ;
    },
    setHistory(state, data){
        // 把新的搜索记录加到所有
        // console.log(234234)
        state.history.unshift(data);
        // 截取数组的长度为5
        if(state.history.length > 10){
            state.history.length = 10;
        }
    },
}